import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import get_local from '@dfeidao/atom-wxapp/local/get';
import preview_image from '@dfeidao/atom-wxapp/api/media/preview-image';
import render from '@dfeidao/atom-wxapp/render/render';

export default async function a006(fd: IFeidaoAiWeappPage, e: {
	currentTarget: {
		dataset: {
			src: string;
			pic_type: string;
		}
	}
}) {
	const pictures = get_local(fd, 'pictures') as string[];
	const src = e.currentTarget.dataset.src;
	const gif = /\.gif/.test(src);
	console.log(e.currentTarget.dataset.pic_type);
	if (gif) {
		render(fd, {
			pic_type: e.currentTarget.dataset.pic_type,
			gif: src,
			show: true,
			type: '1'
		});
	} else {
		pictures.length ?
			preview_image(pictures, src) :
			preview_image([src], src);
	}
}
